<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/WEB-INF/templates/basic_template.xhtml">
	<ui:define name="content">
		<h:form>
			<br />
			<p:dataTable id="dataTable" var="item"
				value="#{experimentMBean.experimentsList}" paginator="true"
				rows="10"
				paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				rowsPerPageTemplate="5,10,15" paginatorAlwaysVisible="false"
				rendered="#{not empty experimentMBean.experimentsList}">

				<f:facet name="header">Lista de Experimentos</f:facet>

				<p:column headerText="Nome" >
					<h:outputText value="#{item.name}" />
				</p:column>
				
				<p:column headerText="Usuário" rendered="#{userMBean.admin}">
					<h:outputText value="#{item.userr.login}"
						rendered="#{not empty item.name}" />
					<h:outputText value="-" rendered="#{empty item.name}" />
				</p:column>

				<p:column headerText="Modo" style="width: 10%;">
					<div align="center">
						<h:outputText value="Manual" rendered="#{empty item.setPoint}" />
						<h:outputText value="Automático" rendered="#{not empty item.setPoint}" />
					</div>
				</p:column>
				
				<p:column headerText="Carregar" style="width: 5%;">
					<div align="center">
						<p:commandLink action="#{experimentMBean.load(item)}">
							<h:graphicImage url="/icons/execute.png" />
						</p:commandLink>
					</div>
				</p:column>
				<p:column headerText="Visualizar" style="width: 5%;">
					<div align="center">
						<p:commandLink action="#{experimentMBean.view(item)}" rendered="#{not empty item.data}">
							<h:graphicImage url="/icons/view_chart.png" />
						</p:commandLink>
					</div>
				</p:column>
				<p:column headerText="Editar" style="width: 5%;">
					<div align="center">
						<p:commandLink action="#{experimentMBean.editar(item)}"
							update="dataTable">
							<h:graphicImage url="/icons/edit.png" />
						</p:commandLink>
					</div>
				</p:column>
				<p:column headerText="Excluir" style="width: 5%;">
					<div align="center">
						<p:commandLink action="#{experimentMBean.excluir(item)}" ajax="false">
							<h:graphicImage url="/icons/delete.png" />
						</p:commandLink>
					</div>
				</p:column>

			</p:dataTable>

			<h:outputText rendered="#{empty experimentMBean.experimentsList}"
				value="Não existe nenhum experimento cadastrado." />

		</h:form>
	</ui:define>
</ui:composition>
</html>